<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
   pageEncoding="UTF-8"%>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="ssi.tools.Connector" %>
<%@ page import="ssi.beans.User" %>

<%
	User user=(User)session.getAttribute("user");
	String type=user.getTypeOfUser().toString();
	Connection connection = new Connector().getConnection();
	Statement statement = connection.createStatement();
	ResultSet result=null;
	int numberOfRows=0;
	if(type.equals("ADMIN")){
		result = statement.executeQuery("SELECT name, surname, id, email FROM users where email <>'"+user.getEmail()+"'");
		numberOfRows = Connector.getRowCount(result);
	}else if(type.equals("BOSS")){
		result = statement.executeQuery("SELECT name, surname, id, email FROM users where email <>'"+user.getEmail()+"' && type<>'ADMIN'");
		numberOfRows = Connector.getRowCount(result);
	}else if(type.equals("WORKER")){
		result = statement.executeQuery("SELECT name, surname, id, email FROM users where email <>'"+user.getEmail()+"' && type<>'ADMIN' && type<>'BOSS'");
		numberOfRows = Connector.getRowCount(result);
	}
%>
<h2>Edytuj użytkownika:</h2>
<html:form action="editUser" >

<select name="id" id="user">
<option value="0">Wybierz... </option>
<%
int i=0;
while(result.next()){%>
<option value="<%=result.getString("id") %>"><%=result.getString("name")+" "+result.getString("surname") %></option>
<% 
} %>
</select>
<table>
		<tr>
		<td><p>Email:</td> <td><input id="email" name="email" type="text" /></td>
		</tr>
		<tr>
		<td><p>Imię:</td> <td><input id="name" name="name" type="text" /></td> 
		</tr>
		<tr>
		<td><p>Nazwisko:</td> <td><input id="surname" name="surname" type="text" /></td> 
		</tr>
		<tr>
		<td><p>Adres:</td> <td><input id="address" name="address" type="text"/></td> 
		</tr>
		<tr>
		<td><p>Pesel:</td> <td><input id="pesel" name="pesel" type="text"/></td> 
		</tr>
		</table> 
<input type="submit" class='submit' value="Zmien"/><br>
<font color="red"><html:errors property="info" /></font>
</html:form> 

<script type="text/javascript" src="js/jQuery.js"></script>
<script type="text/javascript" src="js/jquery.nivo.slider.js"></script>

<script type="text/javascript" src='js/userChoice.js'></script>



